{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "import requests\n",
    "\n",
    "while True:\n",
    "    city=input(\"请输入城市名称，回车退出：\\n\")\n",
    "    if not city:\n",
    "        break\n",
    "    #print(city)\n",
    "    url=' http://wthrcdn.etouch.cn/weather_mini?city='+city\n",
    "    r = requests.get(url)\n",
    "    message=r.json()\n",
    "    #print(message)\n",
    "    if message['status']==1002:\n",
    "        print('未获得')\n",
    "    else:\n",
    "        weather=message['data']['forecast'][0]\n",
    "        print('{}\\n{}\\n{}\\n{}\\n'.format(weather['date'],weather['high'],weather['low'],weather['type']))\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
